package name.peter.leetcode.daily.alternatinggroup1;

/**
 * 使用滑动窗口进行第二种解法
 */
public class Solution1 {
    public int numberOfAlternatingGroups(int[] colors) {
        int num = 0;
        for (int i = 0; i < colors.length; i++) {
            int left = colors[i];
            int right = colors[(i + 2) % colors.length];
            if (left == right && left != colors[(i + 1) % colors.length]) num++;
        }
        return num;
    }

    public static void main(String[] args) {
        Solution1 solution = new Solution1();
        int[] arr = new int[] {1,1,1};
        int ret = solution.numberOfAlternatingGroups(arr);
        System.out.println(ret);
    }
}
